<?php
$tijiao=$_POST["tijiao"];
if($tijiao == "提交"){
	$user_name=$_POST["user_name"];
	$user_pw=$_POST["user_pw"];
	$today=date("Y-m-d H:i:s");
	$query="select * from user_info where user_name='$user_name'";
	if($rst=$aa->excu($query))  {   //if who the user has been exists
            $user_info=mysql_fetch_array($rst);
            if($user_info["user_pw"]==$user_pw){    //jugdut the password is right or not
                $_SESSION["user_name"]=$user_name;
                
                $query="update user_info set time2='$today' where user_name='". $_SESSION['user_name'] . "'";
                $aa->excu($query);
            }
            else {  //if the password is wrong, show the warning
                jsAlert('错误的用户名或密码!');
            }
        }
        else {  //if there is no user which regex the user id and password user input,and show warning(not exists,this user);
            jsAlert('不存在的用户名!');
        }
}
if($tijiao=="安全退出"){
    $_SESSION["user_name"]="";
}
?>
<table width="98%" border="0" align="center" cellspacing="0" bgcolor="#000000" cellpadding="0">
<tr>
 <form action="#" method="post">
 <td height="25" width="71%" >
 <?php
 if($_SESSION["user_name"]!=""){
 	echo "<font color='#FFFFFF'>欢迎您:".$_SESSION["user_name"]."</font>&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='tijiao' value='安全退出'>";
    }
    else{
 ?>
 <font color="#FFFFFF">	用户名:</font>
  <input type="text" name="user_name"  size="40" maxlength="40"/>
  <font color="#FFFFFF">  密码：</font>
  <input type="password" name="user_pw" size="40" maxlength="40"/>
  <input type="submit" name="tijiao" value="提交"/>
  &nbsp;&nbsp;<font color="#FFFFFF"><a href="register.php">我要注册</a></font>
 <?php } ?>
 </td>
 </form>
</tr>
<tr>
 <td height="25%" width="21" align="left"><?php echo $today ?></td>
</tr>
</table>
<table width="98%" border="0" align="center" cellspacing="0" cellpadding="0">
    <tr>
      <td height="25" align="right">帖子总数<?php echo $bb->note_num(); ?>&nbsp;&nbsp;
       会员总数:<?php echo $bb->user_num(); ?>&nbsp;&nbsp;
      欢迎新会员:<?php echo $bb->last_user_name(); ?>
      </td>
    </tr>
    <tr>
      <td height="25">
      </td>
    </tr>
  </table>